using System;
using System.Text;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace BackA2.Controllers
{
    [ApiController]
    [Route("[controller]")]
    [ApiExplorerSettings(IgnoreApi = true)]
    public class Ids4Controller : ControllerBase
    {

        [AllowAnonymous]
        [HttpGet(nameof(IndexToken))]
        public IActionResult IndexToken()
        {
 
            Console.WriteLine($"{nameof(Ids4Controller)} -  {nameof(IndexToken)} 端口号:" + HttpContext.Request.Host.Port);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("{");
            foreach (var key in Request.Query.Keys)
            {
                sb.AppendLine($"\"{key}\":\"{Request.Query[key].ToString()}\",");
            }
            sb.AppendLine("\"友情提示:\":\"请手动copy 地址栏# 后面的 access_token 参数值, 后台接口无法获得 ,如果是postman请求的,请查看console输出的值,然后获取 access_token\"");
            sb.AppendLine("}");
            var txt = sb.ToString();
            return new ContentResult { Content = txt, ContentType = "application/json" };

        }
         

        [AllowAnonymous]
        [HttpGet(nameof(IndexCodeToken))]
        public IActionResult IndexCodeToken()
        { 
            Console.WriteLine($"{nameof(Ids4Controller)} -  {nameof(IndexCodeToken)} 端口号:" + HttpContext.Request.Host.Port);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("{");
            foreach (var key in Request.Query.Keys)
            {
                sb.AppendLine($"\"{key}\":\"{Request.Query[key].ToString()}\",");
            }
            sb.AppendLine("\"友情提示:\":\"有些参数请手动copy 地址栏# 后面的值\"");
            sb.AppendLine("}");
            var txt = sb.ToString();
            //dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(txt);
            //return new JsonResult(obj);
            return new ContentResult { Content = txt, ContentType = "application/json" };
        }

        
    }
}
